﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using VersionComparer.Base;

namespace VersionComparer.DataModel.Actions
{
    public class SpecificActionList : List<SpecificAction>
    {
        static SpecificActionList current = LoadSpecificActionList();
        public static SpecificActionList Current
        {
            get
            {
                return current;
            }
        }

        private static SpecificActionList LoadSpecificActionList()
        {
            SpecificActionList newList = new SpecificActionList();

            foreach (var value in AddInsManager.Current.GetObjectInstancesOfType<SpecificAction>())
            {
                newList.Add(value);
            }
            newList.SortActions();
            return newList;
        }

        private int CompareActions(SpecificAction action1, SpecificAction action2)
        {
            int result = action1.Index.CompareTo(action2.Index);
            if (result == 0)
                result = action1.DisplayName.CompareTo(action2.DisplayName);
            return result;
        }
        public void SortActions()
        {
            this.Sort(CompareActions);
            
        }
    }
}
